{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# 主要学习内容\n",
    "- [视频来源](https://www.bilibili.com/video/av38512783)\n",
    "- [黑暗模式](https://blog.csdn.net/Techmonster/article/details/73382535) win\n",
    "- [黑暗模式](https://www.jianshu.com/p/168a2509db79) Ubuntu18.04\n",
    "- jupyter notebook\n",
    "    - 基本使用:整理想法和pyhton交互的有效工具\n",
    "    - markdown 基本语法\n",
    "- Numpy 入门\n",
    "- Pandas入门\n",
    "\n",
    "## Jupyter Notebook\n",
    "\n",
    "### 基本使用：\n",
    "- 终端输入：jupyter notebook\n",
    "- 运行每个cell：\n",
    "    - Shife + Enter\n",
    "    - Ctrl + Enter\n",
    "- 编辑模式：\n",
    "    - Enter 进入cell\n",
    "    - 鼠标点击 进入\n",
    "    - Tab 代码补全\n",
    "- 命令模式：\n",
    "    - Esc 编辑模式到命令模式\n",
    "    - 鼠标点击非cell 编辑模式到命令模式\n",
    "    - Y cell到code模式\n",
    "    - M cell到markdown模式\n",
    "    - A 在cell上面添加cell\n",
    "    - B 在cell下面添加cell\n",
    "    - 双击D 删除cell\n",
    "    - Z # 撤销\n",
    "\n",
    "### markdown 基础语法：\n",
    "[markdown语法](https://www.jianshu.com/p/191d1e21f7ed)\n",
    "#### 标题语法：\n",
    "- \\# 一级标题\n",
    "- \\## 二级标题\n",
    "#### 缩进语法：\n",
    "- \\- 一级缩进\n",
    "-     \\- 二级缩进（前面一个Tab）\n",
    "#### 链接语法：\n",
    "- \\[描述](url) 可以直接点击描述进入网站\n",
    "- \\! [图片描述\\](url) 可以直接文档显示网络图片\n",
    "- 请学习其他用法比如：逻辑图用法\n",
    "### 一些想法：\n",
    "- 以后就用jupyter markdown记录自己的想法和代码\n",
    "- 详细考察下幻灯片方法和其他语法\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "## Numpy 入门\n",
    "### Numpy介绍优势\n",
    "- numpy：名称由来\n",
    "    - num -> numerical 数值化\n",
    "    - py -> python\n",
    "- nadrray：numpy数据结构（对象）\n",
    "    - n -> 任意个\n",
    "    - d -> dimension 维度\n",
    "    - array -> 排列\n",
    "- 相比list操作速度快是机器学习的基础\n",
    "    - 存储风格：ndarray-相同类型-通用型不高 list相反\n",
    "    - 并行计算：向量计算\n",
    "    - 底层语言：C语言写成支持真正的多线层"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[33 65 90 45 85]\n",
      " [65 36 48 54 68]\n",
      " [54 78 95 62 45]\n",
      " [85 65 36 45 98]\n",
      " [68 78 69 23 65]]\n"
     ]
    }
   ],
   "source": [
    "score = np.array([[33,65,90,45,85],[65,36,48,54,68],[54,78,95,62,45],[85,65,36,45,98],[68,78,69,23,65]])\n",
    "print(score)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### ndrray属性"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 形状（重点）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5, 5)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "score.shape #形状元组表示"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "score.ndim #维度几维数组一般2维"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "25"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "score.size #这个数组有多少个元素组成"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### 理解形状维度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(4, 3)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.array([[1,2,6],[3,9,5],[10,34,21],[55,33,4]])\n",
    "a.shape #()中的第一个数对应第一个大[]有4个元素、第二个数对应第二个[]3个元素 好好理解下重要概念"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2, 2, 3)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b = np.array([[[1,2,3],[2,3,4]],[[2,5,8],[4,8,9]]])\n",
    "b.shape #同样第一个大[]2、第二个[]2、第三个[]3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(4,)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c = np.array([1,2,3,4])\n",
    "c.shape #只有一个[]一唯 (4)为了区分 (4,)好一点 所以4的这个位置表示的就是 一 维"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "score.itemsize #一个元素多少字节"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dtype('int32')"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "score.dtype #数据类型、int默认 int64、float默认 float64"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = np.array([1.2,1.8,1.9],dtype = np.float32)# dtype='float32'一样"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dtype('float32')"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.dtype"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### ndarray基础操作\n",
    "- np.函数名()\n",
    "- ndarray.方法()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 生成0、1数组（方法）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0.]])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.zeros(shape=(4,4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 1, 1, 1, 1, 1],\n",
       "       [1, 1, 1, 1, 1, 1],\n",
       "       [1, 1, 1, 1, 1, 1]], dtype=int64)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.ones(shape=(3,6),dtype='int64')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 现在数组生产"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "data=np.array(score)# 与 np.copy()一样深拷贝\n",
    "data1 = np.asarray(score)#浅拷贝会根据score变而变"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 生成固定范围的素组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0. ,  2.5,  5. ,  7.5, 10. ])"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.linspace(0,10,5)#从0到最后一个10 都是闭合 生产5个数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 2, 4, 6, 8])"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.arange(0,10,2)#从0到9 step=2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 随机数生成（重点）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 0.06446041 -0.40838779  0.43344484 ...  0.327983   -0.29301097\n",
      "  0.76976525]\n"
     ]
    }
   ],
   "source": [
    "data1 = np.random.uniform(low=-1,high=1,size=1000000)#随机生成-1 到 1 之间 1百万个平均分布数\n",
    "print(data1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 1600x640 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "#1、创建画布\n",
    "plt.figure(figsize=(20,8),dpi=80)\n",
    "#2、绘制直方图\n",
    "plt.hist(data1,1000)#1000多少样本\n",
    "#3、展示直方图\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1.76081923 1.70844172 1.5180567  ... 1.65157272 1.61580173 1.7791055 ]\n"
     ]
    }
   ],
   "source": [
    "data2 = np.random.normal(loc=1.75,scale=0.1,size=1000000,)#随机生产 轴1.75，方差0.1 正态分布数字1百万\n",
    "print(data2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABQ0AAAIKCAYAAACJJmmvAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAMTQAADE0B0s6tTgAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3X+M5Hd93/HXO2x8JjlkYoKEzeFbIhAY4hhViFZVmlBIS+CkunGKEoQxblpQDaVN3LS6ilIhoSTXFplGl+IkpvxysOJAIIq5FjVUgSRKMDUprZPaSR37jPdIoiCSkKsdxz8+/WNmYb7L7uzs7uzMd2YeD2nE7vfH3mfNzq/nfL7fb7XWAgAAAACw6RvmPQAAAAAAoF9EQwAAAACgQzQEAAAAADpEQwAAAACgQzQEAAAAADpEQwAAAACgQzQEAAAAADpEQwAAAACgQzQEAAAAADpEQwAAAACgY23eA5jUkSNH2tOf/vR5DwMAAAAAFtK5c+f+qrV2ZJJtFyYaPv3pT8/Gxsa8hwEAAAAAC6mq/mTSbR2eDAAAAAB0iIYAAAAAQIdoCAAAAAB0iIYAAAAAQIdoCAAAAAB0iIYAAAAAQIdoCAAAAAB0iIYAAAAAQMeeomFVvauqWlU9o6ouqKr3VtW5qrqnqq4e2e5lVXV3VX2hqj5cVU8ZLt9xHwAAAACgHyaOhlX1iiSXjCx6S5KnJbksyauTvK+qLq6qC5PcmuS6JMeTPJrkbeP2OeDvAAAAAABM0UTRsKqenuRUkn86sviaJKdba4+31u5KcmeSVwxv97bW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19kczHiIHYKYhLIjW2itba5e31l7UWntRki9m8KAsGELPtNbOJjlbVVcNF/39JPcLhtBbf5nBidpfMPz+JRl8SPfw3EYEK6qq1jK4sMkTSV67NUC01r6Y5K4k/2i46B8m+ZRgCLO32/11uM31GRyW/DLBcPGYaQg9UlX3JlnL4Fwt9yX5gyS/m+RXW2u3b9n2bJIfbK19ZtbjBHa/v1bV8zK4cNElSf44g4ui3DWv8cKqm+A++4YkJzN44/PnSU621j45r/HCqhrOSLolg/vppjuHt79orf1MVT03g/OmPSvJ/Ule11p7YOaDhRW32/01yZkkDybZyNeOmEuS57XWHp/VONk/0RAAAAAA6HB4MgAAAADQIRoCAAAAAB2iIQAAAADQIRoCAAAAAB2iIQAAAADQIRoCAAAAAB2iIQAAAADQIRoCAAAAAB2iIQAAAADQIRoCAAAAAB3/Hzkkco6XunvXAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 1600x640 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "#1、创建画布\n",
    "plt.figure(figsize=(20,8),dpi=80)\n",
    "#2、绘制直方图\n",
    "plt.hist(data2,1000)#1000多少样本\n",
    "#3、展示直方图\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 随机生产2周8个股票数据\n",
    "- ndrray.reshape(shape) 重新按照顺序排形状，生成新的数据不在元数据上改。\n",
    "- ndrray.size(shape) 与上面一样只是直接在原始数据上改\n",
    "- ndrray.T 真正的行列呼唤"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[-0.33885913 -0.90189531  0.5936543   0.45909395  0.4284402   0.0371458\n",
      "   2.11230308  1.63117942 -0.92105503  1.5217585 ]\n",
      " [-0.73828394  0.08180536  1.16842542 -0.37991997  0.36856755 -1.6830281\n",
      "   0.48511654 -0.08122701  0.7768931   0.16330097]\n",
      " [-1.86396517  1.53202734 -0.45138319 -0.0347252   0.08783417 -0.77988643\n",
      "  -1.55646164 -0.15631092 -1.09258736  0.85317964]\n",
      " [-1.21721658 -0.69955748 -0.68343262  1.30325724 -3.0429308   1.00459381\n",
      "  -0.87066204 -0.37442671  1.41802846  0.76922324]\n",
      " [-2.28856039 -1.05401618  0.2167811   0.37519575  0.34120968  0.23682847\n",
      "  -0.56141076  0.56152515  0.91830699  1.02111854]\n",
      " [-0.373509   -0.71725247  0.43643602 -0.94896988  0.04675056 -0.24514275\n",
      "   1.61847057 -0.55631629  0.5649199   0.04208583]\n",
      " [ 1.65072644  1.14793589  0.6526876  -1.02205666 -0.41951687 -2.31580074\n",
      "  -0.22611937 -0.60038568  2.55885537  0.84512233]\n",
      " [-0.60751782  2.01517466  0.32684189 -1.39260246 -0.86020141 -0.21098653\n",
      "  -0.44591402  0.22852576  0.62194478  0.74717869]]\n"
     ]
    }
   ],
   "source": [
    "stock = np.random.normal(loc=0,scale=1,size=(8,10))\n",
    "print(stock)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.33885913, -0.90189531,  0.5936543 ,  0.45909395,  0.4284402 ,\n",
       "         0.0371458 ,  2.11230308,  1.63117942, -0.92105503,  1.5217585 ],\n",
       "       [-0.73828394,  0.08180536,  1.16842542, -0.37991997,  0.36856755,\n",
       "        -1.6830281 ,  0.48511654, -0.08122701,  0.7768931 ,  0.16330097],\n",
       "       [-1.86396517,  1.53202734, -0.45138319, -0.0347252 ,  0.08783417,\n",
       "        -0.77988643, -1.55646164, -0.15631092, -1.09258736,  0.85317964],\n",
       "       [-1.21721658, -0.69955748, -0.68343262,  1.30325724, -3.0429308 ,\n",
       "         1.00459381, -0.87066204, -0.37442671,  1.41802846,  0.76922324],\n",
       "       [-2.28856039, -1.05401618,  0.2167811 ,  0.37519575,  0.34120968,\n",
       "         0.23682847, -0.56141076,  0.56152515,  0.91830699,  1.02111854],\n",
       "       [-0.373509  , -0.71725247,  0.43643602, -0.94896988,  0.04675056,\n",
       "        -0.24514275,  1.61847057, -0.55631629,  0.5649199 ,  0.04208583],\n",
       "       [ 1.65072644,  1.14793589,  0.6526876 , -1.02205666, -0.41951687,\n",
       "        -2.31580074, -0.22611937, -0.60038568,  2.55885537,  0.84512233],\n",
       "       [-0.60751782,  2.01517466,  0.32684189, -1.39260246, -0.86020141,\n",
       "        -0.21098653, -0.44591402,  0.22852576,  0.62194478,  0.74717869]])"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.33885913, -0.90189531,  0.5936543 ,  0.45909395,  0.4284402 ,\n",
       "         0.0371458 ,  2.11230308,  1.63117942],\n",
       "       [-0.92105503,  1.5217585 , -0.73828394,  0.08180536,  1.16842542,\n",
       "        -0.37991997,  0.36856755, -1.6830281 ],\n",
       "       [ 0.48511654, -0.08122701,  0.7768931 ,  0.16330097, -1.86396517,\n",
       "         1.53202734, -0.45138319, -0.0347252 ],\n",
       "       [ 0.08783417, -0.77988643, -1.55646164, -0.15631092, -1.09258736,\n",
       "         0.85317964, -1.21721658, -0.69955748],\n",
       "       [-0.68343262,  1.30325724, -3.0429308 ,  1.00459381, -0.87066204,\n",
       "        -0.37442671,  1.41802846,  0.76922324],\n",
       "       [-2.28856039, -1.05401618,  0.2167811 ,  0.37519575,  0.34120968,\n",
       "         0.23682847, -0.56141076,  0.56152515],\n",
       "       [ 0.91830699,  1.02111854, -0.373509  , -0.71725247,  0.43643602,\n",
       "        -0.94896988,  0.04675056, -0.24514275],\n",
       "       [ 1.61847057, -0.55631629,  0.5649199 ,  0.04208583,  1.65072644,\n",
       "         1.14793589,  0.6526876 , -1.02205666],\n",
       "       [-0.41951687, -2.31580074, -0.22611937, -0.60038568,  2.55885537,\n",
       "         0.84512233, -0.60751782,  2.01517466],\n",
       "       [ 0.32684189, -1.39260246, -0.86020141, -0.21098653, -0.44591402,\n",
       "         0.22852576,  0.62194478,  0.74717869]])"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock.reshape((10,8))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 类型修改去重复"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "#1、类型修改 ndarray.astype(type)\n",
    "#2、本地系列化 ndarray.tostring()\n",
    "#3、数组去重复 ndarray.unique()\n",
    "#或者 data=ndarray.flatten()#把二位数组变成一位再用set,set(data)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### ndarray运算\n",
    "- 逻辑运算\n",
    "- 统计运算\n",
    "- 数组间运算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[False, False,  True, False, False, False,  True,  True, False,\n",
       "         True],\n",
       "       [False, False,  True, False, False, False, False, False,  True,\n",
       "        False],\n",
       "       [False,  True, False, False, False, False, False, False, False,\n",
       "         True],\n",
       "       [False, False, False,  True, False,  True, False, False,  True,\n",
       "         True],\n",
       "       [False, False, False, False, False, False, False,  True,  True,\n",
       "         True],\n",
       "       [False, False, False, False, False, False,  True, False,  True,\n",
       "        False],\n",
       "       [ True,  True,  True, False, False, False, False, False,  True,\n",
       "         True],\n",
       "       [False,  True, False, False, False, False, False, False,  True,\n",
       "         True]])"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#对涨跌幅大于0.5的标记\n",
    "stock>0.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.5936543 , 2.11230308, 1.63117942, 1.5217585 , 1.16842542,\n",
       "       0.7768931 , 1.53202734, 0.85317964, 1.30325724, 1.00459381,\n",
       "       1.41802846, 0.76922324, 0.56152515, 0.91830699, 1.02111854,\n",
       "       1.61847057, 0.5649199 , 1.65072644, 1.14793589, 0.6526876 ,\n",
       "       2.55885537, 0.84512233, 2.01517466, 0.62194478, 0.74717869])"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#通过逻辑数组定位选择大于0.5的-布尔索引\n",
    "stock[stock>0.5]#布尔索引定位后就可以赋值操作"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 通用判断函数\n",
    "判断stock[0:2,0:5]是否都是上涨\n",
    "> np.all(stock[0:2,0:5]>0) #每个元素满足条件才返回 True\n",
    "- np.all(布尔值)返回布尔值\n",
    "\n",
    "判断前5支股票是否有上涨\n",
    "> np.any(stock[0:5,:]>0) # 其中有一个元素满足条件就返回 True\n",
    "- np.any(布尔值)返回布尔值\n",
    "\n",
    "#### 三元运算重要\n",
    "判断前四只股票前四天上涨的情况 True设为1、False设为0\n",
    "> np.where(stock[:4,:4]>0,1,0) # 返回值是修改过的ndarray\n",
    "- np.where(布尔值,正确的返回值、错误的返回的值)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[False, False,  True, False, False, False, False, False, False,\n",
       "        False],\n",
       "       [False, False, False, False, False, False, False, False,  True,\n",
       "        False],\n",
       "       [False, False, False, False, False, False, False, False, False,\n",
       "         True],\n",
       "       [False, False, False, False, False, False, False, False, False,\n",
       "         True],\n",
       "       [False, False, False, False, False, False, False,  True,  True,\n",
       "        False],\n",
       "       [False, False, False, False, False, False, False, False,  True,\n",
       "        False],\n",
       "       [False, False,  True, False, False, False, False, False, False,\n",
       "         True],\n",
       "       [False, False, False, False, False, False, False, False,  True,\n",
       "         True]])"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(stock<1)&(stock >0.5)\n",
    "#np.logical_and 或 np.logical_or\n",
    "np.logical_and(stock<1,stock >0.5) #返回布尔索引"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "####  统计运算\n",
    "- np.max(adarray,axis=0) 最大值\n",
    "- np.min、np.mean、np.std等\n",
    "- np.argmax(data,axis=0) 最大值位置\n",
    "- np.argmin(data,axis=0) 最小值位置\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 数组与数的运算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "arr = np.array([[2,3,3,1],[4,55,6,333]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 4,  6,  6,  2],\n",
       "       [88, 10, 12,  6]])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr*2 #所有都乘以2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 3, 4, 5, 1, 3, 4, 5, 1, 3, 4, 5]"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a= [1,3,4,5] #对比 列表乘 列表不能想加。\n",
    "a*3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 数组与数组间运算\n",
    "广播机制 broadcast\n",
    "- 对应维度想等\n",
    "- 维度等于一（或）\n",
    "> 例子：[视频](https://www.bilibili.com/video/av38512783/?p=29)\n",
    "- A.shape (1,7,1,9)#四位数组\n",
    "- B.shape (5,7,8) #三位数据\n",
    "- 1与5满足维度有一个等于一\n",
    "- 7与7维度想等\n",
    "- 1与8满足维度有一个等于一\n",
    "- 都满足就可以运算\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 矩阵运算 matrix （重要）\n",
    "1. 矩阵一定是二位维\n",
    "2. 矩阵存储 np.array()、np.mat()将数组变成矩阵存储\n",
    "> 存储不同运用的方法不一样\n",
    "3. A(M,N) * B(N,L) = C(M,L) #必须A矩阵 列 于B矩阵行 想等\n",
    "4. 意义看下面案列 期中考试与期末考试得分 加权 平均 期中0.3，期末0.7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [],
   "source": [
    "#转换矩阵相乘\n",
    "a=np.array([[80,90],[85,43],[77,98],[87,98],[89,67]])\n",
    "a=np.mat(a)#转换成矩阵然后运算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [],
   "source": [
    "b=np.array([[0.3],[0.7]])\n",
    "b=np.mat(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[87. ],\n",
       "        [55.6],\n",
       "        [91.7],\n",
       "        [94.7],\n",
       "        [73.6]])"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a*b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[87. ],\n",
       "       [55.6],\n",
       "       [91.7],\n",
       "       [94.7],\n",
       "       [73.6]])"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#用array存储用np.函数相乘\n",
    "a=np.array([[80,90],[85,43],[77,98],[87,98],[89,67]])\n",
    "b=np.array([[0.3],[0.7]])\n",
    "np.matmul(a,b)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 合并与分割\n",
    "1. np.vstack(a,b)、np.concatenate((a,b),axis=0) #垂直合并\n",
    "2. np.hstack(a,b)、np.concatenate((a,b),axis=1) #水平合并\n",
    "3. 分割用 np.split 可以按照份数和值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
